{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "basename.py\n",
      "basename.py is being run directly\n"
     ]
    }
   ],
   "source": [
    "print('basename.py') #自己或者别人导入该模块时，都会执行该模块中的代码\n",
    "def test():\n",
    "    print('test')\n",
    "if __name__ == '__main__':\n",
    "    print('basename.py is being run directly')\n",
    "else:\n",
    "    print('basename.py is being imported into another module')\n",
    "# 输出\n",
    "# basename.py\n",
    "# basename.py is being run directly"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0rc2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
